#ifndef _HTTPSERVERREQUESTIMPL_HPP_
#define _HTTPSERVERREQUESTIMPL_HPP_

#include "jhdefs.hpp"
#include "net/HTTPServerRequest.hpp"
#include "net/HTTPServerResponse.hpp"
#include "net/HTTPServerSession.hpp"
#include "net/HTTPServerParams.hpp"
#include "net/SocketAddress.hpp"
#include "net/StreamSocket.hpp"
#include "utils/autoptr.hpp"
using JHCPP::utils::TAutoPtr;
#include <istream>
#include <string>

NET_NAMESPACE_BEGIN

class CHTTPServerResponseImpl;

class CHTTPServerRequestImpl : public CHTTPServerRequest
{
public:
	CHTTPServerRequestImpl(CHTTPServerResponseImpl& response, CHTTPServerSession& session, CHTTPServerParams* pParams);
	~CHTTPServerRequestImpl();

	std::istream& stream();

	bool expectContinue() const;

	const CSocketAddress& clientAddress() const;
	const CSocketAddress& serverAddress() const;

	const CHTTPServerParams& serverParams() const;
	CHTTPServerResponse& response() const;
	CStreamSocket& socket();
	CStreamSocket detachSocket();

protected:
	static const std::string EXPECT;

private:
	CHTTPServerResponseImpl&		m_response;
	CHTTPServerSession&				m_session;
	std::istream*					m_pStream;
	TAutoPtr<CHTTPServerParams>		m_pParams;
	CSocketAddress					m_clientAddress;
	CSocketAddress					m_serverAddress;
};

NET_NAMESPACE_END

#endif
